<template>
  <div class="content">
    <!-- 个人中心-我的收藏 -->
    <div class="favorite">
      <div class="left">
        <p><img :src="img" alt="" /></p>
        <p>{{ name }}</p>
        <div v-for="(item, index) in myself" :key="index">
          <router-link :to="item.url">
            <p><img :src="item.image" alt="" /></p>
            <p>{{ item.text }}</p>
            <p class="jian"><img :src="item.right" alt="" /></p>
          </router-link>
        </div>
      </div>
      <div class="right">
        <div class="da">
          <p>
            <img src="../../assets/dashou.png" alt="" />
            {{ shouc }}
          </p>
        </div>
        <div class="con" v-for="(item, index) in list" :key="index">
          <p class="grey">{{ item.text }}</p>
          <p class="grey">{{ item.time }}</p>
          <p>
            <router-link to="/model">
              <span>{{ item.look }}</span>
            </router-link>
            <span @click="del(index)" style="cursor: pointer">{{
              item.delete
            }}</span>
          </p>
        </div>
        <!-- <el-col :span="24" class="toolbar pageBar">
          <el-pagination
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            layout=" prev, pager, next,total,jumper"
            :total="total"
            background
          >
          </el-pagination>
        </el-col> -->
      </div>
    </div>
  </div>
</template>
<script>
// import Vue from "vue";
// import { Table, TableColumn, Pagination } from "element-ui";
// import VueResource from "vue-resource";
// Vue.use(Table);
// Vue.use(TableColumn);
// Vue.use(Pagination);
// Vue.use(VueResource);
export default {
  data() {
    return {
      name: "用户名称",
      img: require("../../assets/tx_2.png"),
      myself: [
        {
          image: require("../../assets/my.png"),
          text: "个人信息",
          right: require("../../assets/you.png"),
          url: "/Message",
        },
        {
          image: require("../../assets/time.png"),
          text: "历史答卷",
          right: require("../../assets/you.png"),
          url: "/Year",
        },
        {
          image: require("../../assets/shounow.png"),
          text: "我的收藏",
          right: require("../../assets/you1.png"),
          url: "/Favorite",
        },
      ],
      shouc: "我的收藏",
      list: [
        {
          text: "Java基础练习",
          time: "2021-04-12 09:10:19",
          look: "查看",
          delete: "删除",
        },
        {
          text: "Java基础练习",
          time: "2021-04-12 09:10:19",
          look: "查看",
          delete: "删除",
        },
        {
          text: "Java基础练习",
          time: "2021-04-12 09:10:19",
          look: "查看",
          delete: "删除",
        },
      ],
      // tableData: [],
      // currentPage: 1, //当前页
      // total: 3, //数据总条数
      // pageSize: 10, //每页显示的数据条数
    };
  },
  mounted() {
    // chrome
    document.body.scrollTop = 0;
    // firefox
    document.documentElement.scrollTop = 0;
    // safari
    window.pageYOffset = 0;
  },
  methods: {
    //该方法用来从后台拉取数据，以get方式请求
    //例如：默认每页显示10条数据，当用户点击页码1时，向后端请求第0~9条数据
  //   getData() {
  //     var start = (this.currentPage - 1) * this.pageSize; //请求的数据从第start条开始
  //     var end = this.currentPage * this.pageSize - 1; //到第end条结束
  //     this.$http.get("/api/v1/get_data/?start=" + start + "&end=" + end).then(
  //       function (response) {
  //         this.tableData = response.body.logs;
  //       },
  //       // function (err) {
  //       //   // console.log(err);
  //       // }
  //     );
  //   },
  //   //该方法当用户点击页码改变时触发，val为切换到的页码，页码变化后向后台请求新的数据
  //   handleCurrentChange(val) {
  //     this.currentPage = val;
  //     this.getData();
  //   },
    del(index) {
    this.list.splice(index,1)
    // console.log('q1w2e3r4tghn')
  }
  },
  //该方法为组件创建前的钩子函数，主要用来初始化表格，当表格被加载出来即向后台先请求前10条数据
  // beforeCreate: function () {
  //   this.$http.get("/api/v1/get_data/?start=0&end=10").then(
  //     function (response) {
  //       this.total = response.body.log_total;
  //       this.tableData = response.body.logs;
  //     },
  //     function () {
  //       // console.log(err);
  //     }
  //   );
  // },
  
};
</script>
<style lang="scss" scoped>
.content {
  width: 100%;
  font-size: 16px;

  p {
    margin: 0;
  }

  .favorite {
    width: 65%;
    margin: 0 auto;
    // min-width: 1066px;
    margin-top: 2rem;
    justify-content: space-between;
    display: flex;

    .left {
      width: 22%;
      padding: 2rem 2%;
      box-shadow: 0px 5px 20px 0px rgba(116, 116, 116, 0.35);
      border-radius: 10px;
      padding-bottom: 10rem;

      > p {
        text-align: center;
        color: #666666;
        margin-bottom: 1rem;
      }

      > div {
        width: 100%;
        padding: 1rem 0;
        border-top: 1px solid #d0d0d0;
        color: #666666;

        a {
          justify-content: space-between;
          display: flex;
          text-decoration: none;
          color: #666666;
        }

        .jian {
          width: 10%;

          img {
            width: 100%;
            vertical-align: middle;
          }
        }
      }
      > div:nth-child(5) {
        // background: #0096f6;
        
        > a {
          color: #0096f6 !important;
        }
      }
    }

    .right {
      width: 70%;
      box-shadow: 0px 5px 20px 0px rgba(116, 116, 116, 0.35);
      border-radius: 10px;

      p {
        margin: 0;
      }

      .da {
        width: 96%;
        padding: 2rem 2%;
        color: #0096f6;
        font-size: 24px;
        border-bottom: 2px solid #d9d9d9;
        padding-bottom: 1rem;

        img {
          width: 4%;
          vertical-align: middle;
        }
      }

      .con {
        width: 94%;
        margin: 0 auto;
        padding: 1.4rem 0;
        justify-content: space-between;
        display: flex;
        border-bottom: 1px solid #d0d0d0;

        .grey {
          color: #999999;
        }

        p:nth-child(3) {
          width: 24%;
        }

        span:nth-child(1) {
          padding: 0.3rem 8%;
          background: #0096f6;
          border-radius: 5px;
          color: #fff;
        }

        span:nth-child(2) {
          padding: 0.3rem 8%;
          background: #ff0000;
          border-radius: 5px;
          color: #fff;
          margin-left: 4%;
        }
      }

      /deep/ .el-pagination {
        text-align: center;
        margin-top: 1rem;
      }

      // .block {
      //   text-align: center;
      //   margin-top: 3rem;
      // }
    }
  }
}
</style>